import { colorMix } from '@/utils/color'
import XEUtils from 'xe-utils'
import { deepMerge } from '@/utils'
import { getThemeColor } from '../../../helper/theme'
export const rankContinuousVisualMap = (options, systemConfig, isMap = false, isPrimary = false) => {
  const initOptions: any = options
  const chartThemeColor = getThemeColor(systemConfig)
  let customVisualMap = {}
  if (XEUtils.isObject(initOptions.visualMap)) {
    customVisualMap = initOptions.visualMap
  }
  const initVisualMap = {
    type: 'continuous',
    dimension: 0,
    min: 0,
    max: isMap ? initOptions.series[0].data[0].value : XEUtils.max(initOptions.series[0].data, ''),
    inRange: {
      color: isMap && isPrimary ? [colorMix(chartThemeColor[0], '#ffffff', 0.9), colorMix(chartThemeColor[0], '#000000', 0.3)] : [chartThemeColor[4], chartThemeColor[3], chartThemeColor[2], chartThemeColor[1], chartThemeColor[0]]
    },
    textStyle: {
      color: systemConfig.value.isLight ? '#6e7079' : 'rgba(255,255,255,.5)'
    }
  }
  initOptions.visualMap = deepMerge(customVisualMap, initVisualMap)
  return initOptions
}
